import Vue from "vue"
import VueRouter from "vue-router";

// 引入组件
import home from '../pages/home/home.vue';
import list from '../pages/list/list.vue';
import shopcar from '../pages/shopcar/shopcar.vue';
import user from '../pages/user/user.vue';
import goodsDetail from '../pages/goodsDetail/goodsDetail.vue';
Vue.use(VueRouter)

const routes = [{
    path: "/",
    redirect:"/home"
}, {
    path: "/home",
    name:"home",
    component: home,
    meta:{
        TabbarShow:true,//是否显示底部标签栏
        keepAlive:true,//是否需要缓存
    }
}, {
    path: "/list",
    name:"list",
    props:true,
    component: list,
    meta:{
        TabbarShow:true,
        keepAlive:false,//是否需要缓存
    }
}, {
    path: "/shopcar",
    name:"shopcar",
    component: shopcar,
    meta:{
        TabbarShow:true,
        keepAlive:false,//是否需要缓存
    }
}, {
    path: "/user",
    name:"user",
    component: user,
    meta:{
        TabbarShow:true,
        keepAlive:true,//是否需要缓存
    }
}, {
    path: "/goodsDetail/:id",
    name:"goodsDetail",
    props:true,
    component: goodsDetail,
    meta:{
        TabbarShow:false
    }
}]
var router = new VueRouter({
    mode:"history",
    routes,
    scrollBehavior (to, from, savedPosition) {
        if (savedPosition) {
          return savedPosition
        } else {
          return { x: 0, y: 0 }
        }
      }
    
})

export default router;